import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

export const Status = {
  DISCONNECTED: 'DISCONNECTED',
  CONNECTED: 'CONNECTED',
  CONNECTING: 'CONNECTING',
  FLASHING: 'FLASHING',
  ERROR: 'ERROR',
  MONITORING: 'MONITORING',
};

export const useSerialStore = defineStore('serial', () => {
  const flashSize = ref('4M')
  const compress = ref(true)
  const flashMode = ref('DIO')
  const flashFreq = ref(40);
  const connectStatus = ref(Status.DISCONNECTED)


  const doubleCount = computed(() => flashFreq.value * 2)

  function setConnectStatus(status) {
    connectStatus.value = status
  }

  return {
    flashSize,
    compress,
    flashMode,
    flashFreq,
    connectStatus,
    setConnectStatus
  }
})
